# -*- coding: utf-8 -*-
# @Time    : 2024/2/1 20:58
# @Author  : micah
# @File    : 7.切换标签页.py
# @Software: PyCharm


import time
from selenium import webdriver

browser = webdriver.Chrome()

js_code = 'window.open("https://www.bing.com")'
browser.execute_script(js_code)

js_code = 'window.open("https://www.google.com")'
browser.execute_script(js_code)

time.sleep(2)

# 切换:switch_to.window[标签页切换]
browser.switch_to.window(browser.window_handles[1])
time.sleep(3)
browser.switch_to.window(browser.window_handles[2])
time.sleep(3)

browser.close()
